import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { AccountService } from './account.service';
import {
  AccountListDto,
  BatchCreateAccountDto,
  CreateAccountDto,
  UpdateAccountDto,
} from './account.dto';

@ApiTags('账号管理')
@ApiBearerAuth()
@Controller('account')
export class AccountController {
  constructor(private accountService: AccountService) {}

  @Get('/student/list')
  @ApiOperation({ summary: '学生账号列表' })
  async studentAccountList(@Query() query: AccountListDto) {
    return await this.accountService.find(query);
  }

  @Post('/create')
  @ApiOperation({ summary: '添加账号' })
  async createAccount(@Body() data: CreateAccountDto) {
    return await this.accountService.create(data);
  }

  @Put('/update')
  @ApiOperation({ summary: '更新账号' })
  async updateAccount(@Body() data: UpdateAccountDto) {
    return await this.accountService.update(data);
  }

  @Post('/create/batch')
  @ApiOperation({ summary: '批量添加账号' })
  async batchCreateAccount(@Body() data: BatchCreateAccountDto) {
    return await this.accountService.batch(data);
  }
}
